#include "z_block.h"

z_block::z_block(int posy, int posx)
{
    //Initialize matrix (T-Position)
    for(int i=0; i<4; i++)
    {
        for(int j=0; j<4; j++)
        {
            if(((i==1) && ((j>=0)&&(j<=1))) || ((i==2) && ((j>=1)&&(j<=2))))
                m_pos_matrix[i][j] = true;
            else
                m_pos_matrix[i][j] = false;
        }
    }

    //Initialize state, position and color
    m_state = S_LEFT;
    m_position[0] = posy+1;
    m_position[1] = posx-1;
    m_color = C_WHITE;
}

z_block::~z_block()
{
    //dtor
}

void z_block::m_Rotate()
{

    switch(m_state)
    {
        case S_LEFT:
        {
            m_state=S_UP; //Change block state

            //Just update necessary positions
            m_pos_matrix[1][0] = false;
            m_pos_matrix[2][2] = false;

            m_pos_matrix[0][2] = true;
            m_pos_matrix[1][2] = true;

            break;
        }

        case S_UP:
        {
            m_state=S_LEFT; //Change block state

            //Just update necessary positions
            m_pos_matrix[0][2] = false;
            m_pos_matrix[1][2] = false;

            m_pos_matrix[1][0] = true;
            m_pos_matrix[2][2] = true;

            break;
        }
    }
}
